#include <iostream>
#include <unordered_map>

using namespace std;

class Node {
public:
    int val;
    Node* next;
    Node* random;

    Node(int _val) {
        val = _val;
        next = NULL;
        random = NULL;
    }
};

unordered_map<Node*, Node*> code;

Node* copyRandomList(Node* head) {
    if (head == nullptr)
        return head;

    if (!code.count(head))
    {
        Node* newhead = new Node(head->val);

        code[head] = newhead;

        newhead->next = copyRandomList(head->next);
        newhead->random = copyRandomList(head->random);

    }

    return code[head];
}

int main()
{

	return 0;
}